#include <stddef.h>

#include "Collection.h"
#include "HashTable.h"
#include "PointerKey.h"

void Collection::add(ICollectible* c)
{
    table.put(new PointerKey(c), c);
}

void Collection::remove(ICollectible* c)
{
    PointerKey *p = new PointerKey(c);
    table.remove(p);
    delete p;
}

bool Collection::member(ICollectible* c)
{
    PointerKey *p = new PointerKey(c);
    bool res = table.get(p) != NULL;
    delete p;
    return res;
}

bool Collection::isEmpty()
{
    return table.getSize() == 0;
}

int Collection::getSize()
{
    return table.getSize();
}

IIterator *Collection::getIterator()
{
    return table.getIterator();
}
